/**
 *  Create by mason at 2018/11/15
 *  Function: 日志封装
 *  Desc:
 */

import AppConfig from '../config';

const __isDebug__ = AppConfig.LOG_DEBUG_SWITCH;
const __logModel__ = AppConfig.LOG_DEBUG_MODEL;

class LogUtils {

    static v = function(message, ...args){
        if (__isDebug__ && __logModel__.indexOf('v') != -1) {
            try{
                console.log(message, ...args);
            }catch(exception){
                return;
            }
        }
    };

    static i = function(message, ...args){
        if (__isDebug__ && __logModel__.indexOf('i') != -1) {
            try{
                console.info(message, ...args);
            }catch(exception){
                return;
            }
        }
    };

    static d = function(message, ...args){
        if (__isDebug__ && __logModel__.indexOf('d') != -1) {
            try{
                console.debug(message, ...args);
            }catch(exception){
                return;
            }
        }
    };

    static w = function(message, ...args){
        if (__isDebug__ && __logModel__.indexOf('w') != -1) {
            try{
                console.warn(message, ...args);
            }catch(exception){
                return;
            }
        }
    };

    static e = function(message, ...args){
        if (__isDebug__ && __logModel__.indexOf('e') != -1) {
            try{
                console.error(message, ...args);
            }catch(exception){
                return;
            }
        }
    };
};

global.Log = LogUtils;
